package com.strategy.demo03;

public enum Calculate {
    ADD("+"){
        public int exec(int a, int b){
            return a + b;
        }
    },
    SUB("-"){
        public int exec(int a, int b){
            return a - b;
        }
    };

    private String symbol;
    // 枚举类的实例是固定那么几个(取决于在枚举类里面的成员变量有几个),因此不允许外界new,那么构造方法只能是private.
    private Calculate(String symbol){
        this.symbol = symbol;
    }

    public abstract int exec(int a, int b);
}
